package com.advertise.testing;



import java.util.List;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.orm.hibernate3.SessionHolder;
import org.springframework.transaction.support.TransactionSynchronizationManager;

import com.advertise.model.LoginState;
import com.advertise.model.TreeNode;
import com.advertise.model.User;
import com.advertise.service.MenuService_IFace;
import com.advertise.service.UserService_IFace;
import com.advertise.tool.DhtmlxHelper;
import com.advertise.tool.UnitTestForHibernate;

import junit.framework.TestCase;

public class TestUserService extends UnitTestForHibernate {


	
	public void testHibernate(){
		
		
		UserService_IFace userService = (UserService_IFace)getCtx().getBean("userService");
		MenuService_IFace menuService = (MenuService_IFace)getCtx().getBean("menuService");
		
		LoginState loginState = userService.validateLogin("admin","admin");
		System.out.println(loginState);
		List<TreeNode> userMenus = userService.getUserMenus("txh");
		System.out.println("user menu size is "+userMenus.size());
		
		List<TreeNode> currentLevelMenus = menuService.getSubMenusFromMenuList(1,userMenus);
		
		System.out.println(currentLevelMenus.size());
		
		String menuXmlData = DhtmlxHelper.convertListToTreeData(currentLevelMenus, 0);
		
		System.out.println(menuXmlData);
		
	}
}
